NGram

Implements the N-Gram Similarity (Kondrak, 2005) between strings.

The algorithm uses affixing with special character '\0' to increase the weight of first characters. The normalization is achieved by dividing the total similarity score the original length of the longest word.

The similarity is computed as \(1 - distance(X, Y)\).

References

Kondrak, G. (2005-11-02). N-gram similarity and distance. In String processing and information retrieval, lecture notes in computer science (Pages 115-126). Springer Berlin Heidelberg. https://doi.org/10.1007/11575832_13[sci-hub]

Author

Thibault Debatty, solonovamax

See also

Constructors

Link copied to clipboard
constructor(n: Int = DEFAULT_N)

Properties

Link copied to clipboard
val n: Int

Functions

Link copied to clipboard
open override fun distance(s1: String, s2: String): Double

Computes the N-Gram distance of two strings.

Link copied to clipboard
open override fun similarity(s1: String, s2: String): Double

Computes the N-Gram similarity of two strings.